// import Home from '@/pages/Home'
// import Search from '@/pages/Search'
// import Login from '@/pages/Login'
// import Register from '@/pages/Register'
// import Detail from '@/pages/Detail'
// import AddCartSuccess from '@/pages/AddCartSuccess'
// import Cart from '@/pages/Cart'
// import Trade from '@/pages/Trade'
// import Pay from '@/pages/Pay'
// import PaySuccess from '@/pages/PaySuccess'
//路由懒加载
const Home = ()=> import('@/pages/Home')
const Login = ()=> import('@/pages/Login')
const Register = ()=> import('@/pages/Register')
const Search = ()=> import('@/pages/Search')
const Detail = ()=> import('@/pages/Detail')
const AddCartSuccess = ()=> import('@/pages/AddCartSuccess')
const Cart = ()=> import('@/pages/Cart')
const Trade = ()=> import('@/pages/Trade')
const Pay = ()=> import('@/pages/Pay')
const PaySuccess = ()=> import('@/pages/PaySuccess')
export default[
    {
        name:'home',
        path: '/home',
        component:Home,
        //是否显示三级分类导航
        meta:{isTypeNavRequired:true}
        
    },
    {
        name:'search',
        path: '/search',
        component:Search,
        
    },
    {
        name:'login',
        path: '/login',
        component:Login,
        //是否隐藏footer组件
        meta:{isHiddenFooter:true}
    },
    {
        name:'register',
        path: '/register',
        component:Register,
        meta:{isHiddenFooter:true}
    },
    {
        name:'detail',
        path: '/detail/:id',
        component:Detail,
        props:true
    },
    {
        name:'addcartsuccess',
        path: '/addcartsuccess',
        component:AddCartSuccess,
    },
    {
        name:'cart',
        path: '/cart',
        component:Cart,
    },
    {
        name:'trade',
        path: '/trade',
        component:Trade,
        beforeEnter: (to, from, next) => {
			if(from.path === '/cart'){
				next()
			}else{
				next('/home')
			}
		}
    },
    {
        name:'pay',
        path: '/pay',
        component:Pay,
        //使用【路由独享守卫】细化鉴权规则（只有在特定路由，才能去特定路由）。
        beforeEnter: (to, from, next) => {
            if(from.path==='/trade'){
                next()
            }else{
                next('/home')
            }
        }
    },
    {
        name:'paysuccess',
        path: '/paysuccess',
        component:PaySuccess,
       
    },
    {
        path:'/',
        redirect:'/home'
    }
]